// 向上取整
let ceil = (value) => Math.ceil(Number(value));

// 保留两位小数
let keepTwoNum = (value) => Number(value).toFixed(2);

// 处理浮点数
let toFixed = (input, num) => Number(input).toFixed(num)

//采购单状态
let orderStatus=(value,type)=>{
  let status = "";
  if(!type){
      switch (value) {
          case "20":
              status = "礼品部专员已下单";
              break;
          case "22":
              status = "礼品部经理已审批";
              break;
          case "23":
              status = "礼品部经理已打回";
              break;
          case "24":
              status = "礼品部专员已关闭";
              break;
          case "25":
              status = "礼品部经理已关闭";
              break;
  
          default:
              break;
      }
      return status;        
  }
  switch (value) {
      case "5":
          status = "门店已关闭";
          break;
      case "10":
          status = "门店已下单";
          break;
      case "11":
          status = "店长已审批";
          break;
      case "12":
          status = "店长已打回";
          break;
      case "13":
          status = "店长已关闭";
          break;
      case "20":
          status = "礼品部专员已审批";
          break;
      case "21":
          status = "礼品部专员已打回";
          break;
      case "22":
          status = "礼品部经理已审批";
          break;
      case "23":
          status = "礼品部经理已打回";
          break;
      case "24":
          status = "礼品部专员已关闭";
          break;
      case "25":
          status = "礼品部经理已关闭";
          break;

      default:
          break;
  }
  return status;
}

//合并单状态
let mOrderStatus=(value)=>{
  let status = "";
  switch (value) {
      case "10":
          status = "采购专员已合并";
          break;
      case "11":
          status = "采购专员已撤销";
          break;
      case "12":
          status = "采购专员已关闭";
          break;
      case "21":
          status = "采购部已打回";
          break;
      case "20":
          status = "采购专员已确认";
          break;
      case "22":
          status = "采购部已关闭";
          break;
      case "30":
          status = "采购部已通过";
          break;
      case "31":
          status = "财务经理已打回";
          break;
      case "32":
          status = "财务经理已关闭";
          break;
      case "40":
          status = "财务经理已通过";
          break;
      case "41":
          status = "总经办已打回";
          break;
      case "42":
          status = "总经办已关闭";
          break;
      case "50":
          status = "总经办已通过";
          break;

      default:
          break;
  }
  return status;
}

//店外调拨单状态
let sOrderStatus=(value,type)=>{
  let status = "";
  if(type==1){
      switch (value) {
          case "1":
              status = "已创建";
              break;
          case "2":
              status = "已审核";
              break;
          case "3":
              status = "已发货";
              break;
          case "4":
              status = "已收货";
              break;
          case "5":
              status = "已打回";
              break;
          case "6":
              status = "已关闭";
              break;
          default:
              break;
      }   
      return status;     
  }
  switch (value) {
      case "0":
          status = "待审核";
          break;
      case "1":
          status = "待发货";
          break;
      case "2":
          status = "待收货";
          break;
      case "3":
          status = "部分收货";
          break;
      case "4":
          status = "订单完结";
          break;
      case "5":
          status = "收货完成";
          break;
      case "6":
          status = "已关闭";
          break;
      case "10":
          status = type==2?"被打回":"已打回";
          break;
      default:
          break;
  }
  return status;
}

//跨平台调拨状态
let kOrderStatus=(value,type)=>{
  let status = "";
  if(type==1){
      switch (value) {
          case "1":
              status = "已创建";
              break;
          case "2":
              status = "已审核";
              break;
          case "3":
              status = "已发货";
              break;
          case "4":
              status = "已收货";
              break;
          case "5":
              status = "已打回";
              break;
          case "6":
              status = "已关闭";
              break;
          default:
              break;
      }   
      return status; 
  }
  switch (value) {
      case "1":
          status = "待审核";
          break;
      case "2":
          status = "待其他平台确认";
          break;
      case "4":
          status = "出库关闭";
          break;
      case "5":
          status = "待发货";
          break;
      case "6":
          status = "已发货";
          break;
      case "8":
          status = "部分收货";
          break;
      case "9":
          status = "订单完结";
          break;
      case "3":
          status = "已关闭";
          break;
      case "10":
          status = type==2?"被打回":"已打回";
          break;
      default:
          break;
  }
  return status; 
}

//退货单状态
let rOrderStatus=(value,type)=>{
  let status = "";  //type  2:最近操作 3:发货
  if(type==2){
      switch (value) {
          case "10":
              status = "已提交";
              break;
          case "20":
              status = "已审批";
              break;
          case "30":
              status = "已打回";
              break;
          case "40":
              status = "已关闭";
              break;
          case "50":
              status = "已确认";
              break;
          default:
              break;
      }
      return status;       
  }
  switch (value) {
      case "10":
          status = "待审批";
          break;
      case "20":
          status = type==3?"待发货":"审批通过";
          break;
      case "30":
          status = type==1?"被打回":"已打回";
          break;
      case "40":
          status = "已关闭";
          break;
      case "50":
          status = "待收货";
          break;
      case "60":
          status = "部分收货";
          break;
      case "70":
          status = "收货完成";
          break;
      case "80":
          status = "发货关闭";
          break;
      default:
          break;
  }
  return status; 
}

//供应商付款类型
let payTypeName=(value)=>{
  return value==="1"?"先货后款":value==="0"?"先款后货":value==="2"?"分期付款发货":"";
}

//使用区域
let useAreaType=(value)=>{
  return value==1?"礼品机区域":value==2?"礼品柜区域":value==3?"摊位机区域":value==4?"企划区域":value==5?"其他区域":"未配置"
}

//优惠券类型
let couponType=(value)=>{
  return value==1?"代金券":value==2?"满减券":"";
}

export default { //默认导出
  ceil,
  keepTwoNum,
  toFixed,
  orderStatus,
  mOrderStatus,
  sOrderStatus,
  kOrderStatus,
  rOrderStatus,
  payTypeName,
  useAreaType,
  couponType 
}